﻿using Autofac.Core;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 体尺测定
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BodySizeController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly IBodySizeService bodySizeService;
       


        public BodySizeController(IMediator mediator, IBodySizeService bodySizeService)
        {
            _mediator = mediator;
            this.bodySizeService = bodySizeService;
        }

        /// <summary>
        /// 体尺测定添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> Create(BodySizeCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        ///体尺测定显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Results<PageOutput<BodySize>>> GetBodySize(BodySizeListCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 体尺测定删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelBodySizet(BodySizeDelCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 体尺测定反填
        /// </summary>
        /// <param name="BodySizeId"></param>
        /// <returns></returns>

        [HttpGet]
        public async Task<Results<BodySize>> GetFtBodySize(int BodySizeId)
        {
            return Results<BodySize>.DataResult(bodySizeService.GetFtBodySize(BodySizeId));
        }

        /// <summary>
        /// 修改体尺测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Results<int>> Update(BodySizeUpdaCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量删除体尺测定
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelRangeBodySize(BodySizeDelRangeCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
